<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Coverage for c:\program files\python26\lib\multiprocessing\process</title>
<link rel='stylesheet' href='style.css' type='text/css'>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
function toggle_lines(btn, cls) {
    var btn = $(btn);
    var hide = "hide_"+cls;
    if (btn.hasClass(hide)) {
        $("#source ."+cls).removeClass(hide);
        btn.removeClass(hide);
    }
    else {
        $("#source ."+cls).addClass(hide);
        btn.addClass(hide);
    }
}
</script>
</head>
<body>
<div id='header'>
    <div class='content'>
        <h1>Coverage for <b>c:\program files\python26\lib\multiprocessing\process</b> :
            <span class='pc_cov'>27%</span>
        </h1>
        <h2 class='stats'>
            156 statements
            <span class='run hide_run' onclick='toggle_lines(this, "run")'>50 run</span>
            <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
            <span class='mis' onclick='toggle_lines(this, "mis")'>106 missing</span>
            
                <span class='par run hide_run' onclick='toggle_lines(this, "par")'>0 partial</span>
            
        </h2>
    </div>
</div>

<div id='source'>
<table cellspacing='0' cellpadding='0'>
<tr>
<td class='linenos' valign='top'>
<p class='pln'>1</p>
<p class='pln'>2</p>
<p class='pln'>3</p>
<p class='pln'>4</p>
<p class='pln'>5</p>
<p class='pln'>6</p>
<p class='pln'>7</p>
<p class='pln'>8</p>
<p class='stm run hide_run'>9</p>
<p class='pln'>10</p>
<p class='pln'>11</p>
<p class='pln'>12</p>
<p class='pln'>13</p>
<p class='pln'>14</p>
<p class='stm run hide_run'>15</p>
<p class='stm run hide_run'>16</p>
<p class='stm run hide_run'>17</p>
<p class='stm run hide_run'>18</p>
<p class='pln'>19</p>
<p class='pln'>20</p>
<p class='pln'>21</p>
<p class='pln'>22</p>
<p class='pln'>23</p>
<p class='stm run hide_run'>24</p>
<p class='stm run hide_run'>25</p>
<p class='stm mis'>26</p>
<p class='stm mis'>27</p>
<p class='pln'>28</p>
<p class='pln'>29</p>
<p class='pln'>30</p>
<p class='pln'>31</p>
<p class='pln'>32</p>
<p class='stm run hide_run'>33</p>
<p class='pln'>34</p>
<p class='pln'>35</p>
<p class='pln'>36</p>
<p class='stm run hide_run'>37</p>
<p class='pln'>38</p>
<p class='stm run hide_run'>39</p>
<p class='pln'>40</p>
<p class='pln'>41</p>
<p class='pln'>42</p>
<p class='stm mis'>43</p>
<p class='stm mis'>44</p>
<p class='pln'>45</p>
<p class='pln'>46</p>
<p class='pln'>47</p>
<p class='pln'>48</p>
<p class='pln'>49</p>
<p class='stm run hide_run'>50</p>
<p class='pln'>51</p>
<p class='stm mis'>52</p>
<p class='stm mis'>53</p>
<p class='stm mis'>54</p>
<p class='pln'>55</p>
<p class='pln'>56</p>
<p class='pln'>57</p>
<p class='pln'>58</p>
<p class='pln'>59</p>
<p class='stm run hide_run'>60</p>
<p class='pln'>61</p>
<p class='pln'>62</p>
<p class='pln'>63</p>
<p class='pln'>64</p>
<p class='pln'>65</p>
<p class='stm run hide_run'>66</p>
<p class='pln'>67</p>
<p class='stm run hide_run'>68</p>
<p class='stm mis'>69</p>
<p class='stm mis'>70</p>
<p class='stm mis'>71</p>
<p class='stm mis'>72</p>
<p class='stm mis'>73</p>
<p class='stm mis'>74</p>
<p class='stm mis'>75</p>
<p class='stm mis'>76</p>
<p class='stm mis'>77</p>
<p class='stm mis'>78</p>
<p class='stm mis'>79</p>
<p class='stm mis'>80</p>
<p class='pln'>81</p>
<p class='pln'>82</p>
<p class='stm run hide_run'>83</p>
<p class='pln'>84</p>
<p class='pln'>85</p>
<p class='pln'>86</p>
<p class='stm mis'>87</p>
<p class='stm mis'>88</p>
<p class='pln'>89</p>
<p class='stm run hide_run'>90</p>
<p class='pln'>91</p>
<p class='pln'>92</p>
<p class='pln'>93</p>
<p class='stm mis'>94</p>
<p class='stm mis'>95</p>
<p class='pln'>96</p>
<p class='stm mis'>97</p>
<p class='pln'>98</p>
<p class='stm mis'>99</p>
<p class='stm mis'>100</p>
<p class='stm mis'>101</p>
<p class='pln'>102</p>
<p class='stm mis'>103</p>
<p class='stm mis'>104</p>
<p class='stm mis'>105</p>
<p class='pln'>106</p>
<p class='stm run hide_run'>107</p>
<p class='pln'>108</p>
<p class='pln'>109</p>
<p class='pln'>110</p>
<p class='stm mis'>111</p>
<p class='pln'>112</p>
<p class='stm run hide_run'>113</p>
<p class='pln'>114</p>
<p class='pln'>115</p>
<p class='pln'>116</p>
<p class='stm mis'>117</p>
<p class='stm mis'>118</p>
<p class='stm mis'>119</p>
<p class='stm mis'>120</p>
<p class='stm mis'>121</p>
<p class='pln'>122</p>
<p class='stm run hide_run'>123</p>
<p class='pln'>124</p>
<p class='pln'>125</p>
<p class='pln'>126</p>
<p class='stm mis'>127</p>
<p class='stm mis'>128</p>
<p class='stm mis'>129</p>
<p class='stm mis'>130</p>
<p class='stm mis'>131</p>
<p class='stm mis'>132</p>
<p class='stm mis'>133</p>
<p class='pln'>134</p>
<p class='stm run hide_run'>135</p>
<p class='pln'>136</p>
<p class='stm run hide_run'>137</p>
<p class='pln'>138</p>
<p class='stm run hide_run'>139</p>
<p class='pln'>140</p>
<p class='stm mis'>141</p>
<p class='stm mis'>142</p>
<p class='pln'>143</p>
<p class='stm run hide_run'>144</p>
<p class='pln'>145</p>
<p class='pln'>146</p>
<p class='pln'>147</p>
<p class='pln'>148</p>
<p class='stm mis'>149</p>
<p class='pln'>150</p>
<p class='stm run hide_run'>151</p>
<p class='pln'>152</p>
<p class='pln'>153</p>
<p class='pln'>154</p>
<p class='pln'>155</p>
<p class='stm mis'>156</p>
<p class='stm mis'>157</p>
<p class='pln'>158</p>
<p class='stm run hide_run'>159</p>
<p class='pln'>160</p>
<p class='stm mis'>161</p>
<p class='pln'>162</p>
<p class='stm run hide_run'>163</p>
<p class='pln'>164</p>
<p class='pln'>165</p>
<p class='pln'>166</p>
<p class='pln'>167</p>
<p class='stm mis'>168</p>
<p class='pln'>169</p>
<p class='stm run hide_run'>170</p>
<p class='pln'>171</p>
<p class='pln'>172</p>
<p class='pln'>173</p>
<p class='pln'>174</p>
<p class='stm mis'>175</p>
<p class='stm mis'>176</p>
<p class='stm mis'>177</p>
<p class='pln'>178</p>
<p class='stm run hide_run'>179</p>
<p class='pln'>180</p>
<p class='pln'>181</p>
<p class='pln'>182</p>
<p class='pln'>183</p>
<p class='stm mis'>184</p>
<p class='stm mis'>185</p>
<p class='pln'>186</p>
<p class='stm mis'>187</p>
<p class='pln'>188</p>
<p class='stm run hide_run'>189</p>
<p class='pln'>190</p>
<p class='stm run hide_run'>191</p>
<p class='stm mis'>192</p>
<p class='stm mis'>193</p>
<p class='stm mis'>194</p>
<p class='stm mis'>195</p>
<p class='stm mis'>196</p>
<p class='stm mis'>197</p>
<p class='pln'>198</p>
<p class='stm mis'>199</p>
<p class='stm mis'>200</p>
<p class='pln'>201</p>
<p class='stm mis'>202</p>
<p class='pln'>203</p>
<p class='stm mis'>204</p>
<p class='stm mis'>205</p>
<p class='stm mis'>206</p>
<p class='pln'>207</p>
<p class='stm mis'>208</p>
<p class='pln'>209</p>
<p class='stm mis'>210</p>
<p class='pln'>211</p>
<p class='pln'>212</p>
<p class='pln'>213</p>
<p class='pln'>214</p>
<p class='stm run hide_run'>215</p>
<p class='stm mis'>216</p>
<p class='pln'>217</p>
<p class='pln'>218</p>
<p class='stm mis'>219</p>
<p class='stm mis'>220</p>
<p class='stm mis'>221</p>
<p class='stm mis'>222</p>
<p class='stm mis'>223</p>
<p class='stm mis'>224</p>
<p class='stm mis'>225</p>
<p class='stm mis'>226</p>
<p class='stm mis'>227</p>
<p class='stm mis'>228</p>
<p class='stm mis'>229</p>
<p class='stm mis'>230</p>
<p class='stm mis'>231</p>
<p class='stm mis'>232</p>
<p class='pln'>233</p>
<p class='stm mis'>234</p>
<p class='stm mis'>235</p>
<p class='stm mis'>236</p>
<p class='stm mis'>237</p>
<p class='stm mis'>238</p>
<p class='stm mis'>239</p>
<p class='pln'>240</p>
<p class='stm mis'>241</p>
<p class='stm mis'>242</p>
<p class='stm mis'>243</p>
<p class='stm mis'>244</p>
<p class='stm mis'>245</p>
<p class='stm mis'>246</p>
<p class='stm mis'>247</p>
<p class='stm mis'>248</p>
<p class='stm mis'>249</p>
<p class='pln'>250</p>
<p class='stm mis'>251</p>
<p class='stm mis'>252</p>
<p class='pln'>253</p>
<p class='pln'>254</p>
<p class='pln'>255</p>
<p class='pln'>256</p>
<p class='pln'>257</p>
<p class='stm run hide_run'>258</p>
<p class='stm run hide_run'>259</p>
<p class='stm mis'>260</p>
<p class='stm mis'>261</p>
<p class='stm mis'>262</p>
<p class='pln'>263</p>
<p class='pln'>264</p>
<p class='pln'>265</p>
<p class='stm mis'>266</p>
<p class='pln'>267</p>
<p class='pln'>268</p>
<p class='pln'>269</p>
<p class='pln'>270</p>
<p class='pln'>271</p>
<p class='stm run hide_run'>272</p>
<p class='pln'>273</p>
<p class='stm run hide_run'>274</p>
<p class='stm run hide_run'>275</p>
<p class='stm run hide_run'>276</p>
<p class='stm run hide_run'>277</p>
<p class='stm run hide_run'>278</p>
<p class='stm run hide_run'>279</p>
<p class='stm run hide_run'>280</p>
<p class='stm run hide_run'>281</p>
<p class='stm run hide_run'>282</p>
<p class='stm run hide_run'>283</p>
<p class='pln'>284</p>
<p class='stm run hide_run'>285</p>
<p class='stm run hide_run'>286</p>
<p class='pln'>287</p>
<p class='pln'>288</p>
<p class='pln'>289</p>
<p class='pln'>290</p>
<p class='pln'>291</p>
<p class='stm run hide_run'>292</p>
<p class='pln'>293</p>
<p class='stm run hide_run'>294</p>
<p class='stm run hide_run'>295</p>
<p class='stm run hide_run'>296</p>
    
</td>
<td class='text' valign='top'>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Module providing the `Process` class which emulates `threading.Thread`</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># multiprocessing/process.py</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>__all__</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>&#39;Process&#39;</span><span class='op'>,</span> <span class='str'>&#39;current_process&#39;</span><span class='op'>,</span> <span class='str'>&#39;active_children&#39;</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Imports</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>import</span> <span class='nam'>os</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>import</span> <span class='nam'>sys</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>import</span> <span class='nam'>signal</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>import</span> <span class='nam'>itertools</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>ORIGINAL_DIR</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>abspath</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>getcwd</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>except</span> <span class='nam'>OSError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>ORIGINAL_DIR</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Public functions</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>current_process</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return process object representing the current process</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>_current_process</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>active_children</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return list of process objects corresponding to live child processes</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>_cleanup</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>list</span><span class='op'>(</span><span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_children</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>def</span> <span class='nam'>_cleanup</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># check for processes which have finished</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>p</span> <span class='key'>in</span> <span class='nam'>list</span><span class='op'>(</span><span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_children</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>p</span><span class='op'>.</span><span class='nam'>_popen</span><span class='op'>.</span><span class='nam'>poll</span><span class='op'>(</span><span class='op'>)</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_children</span><span class='op'>.</span><span class='nam'>discard</span><span class='op'>(</span><span class='nam'>p</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># The `Process` class</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>Process</span><span class='op'>(</span><span class='nam'>object</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Process objects represent activity that is run in a separate process</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; The class is analagous to `threading.Thread`</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>_Popen</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>group</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>target</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>=</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>=</span><span class='op'>{</span><span class='op'>}</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>group</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>,</span> <span class='str'>&#39;group argument must be None for now&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>count</span> <span class='op'>=</span> <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_counter</span><span class='op'>.</span><span class='nam'>next</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_identity</span> <span class='op'>=</span> <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_identity</span> <span class='op'>+</span> <span class='op'>(</span><span class='nam'>count</span><span class='op'>,</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_authkey</span> <span class='op'>=</span> <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_authkey</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_daemonic</span> <span class='op'>=</span> <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_daemonic</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_tempdir</span> <span class='op'>=</span> <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_tempdir</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_parent_pid</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>getpid</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_target</span> <span class='op'>=</span> <span class='nam'>target</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_args</span> <span class='op'>=</span> <span class='nam'>tuple</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_kwargs</span> <span class='op'>=</span> <span class='nam'>dict</span><span class='op'>(</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_name</span> <span class='op'>=</span> <span class='nam'>name</span> <span class='key'>or</span> <span class='nam'>type</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>__name__</span> <span class='op'>+</span> <span class='str'>&#39;-&#39;</span> <span class='op'>+</span> <span class='xx'>\</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&#39;:&#39;</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>str</span><span class='op'>(</span><span class='nam'>i</span><span class='op'>)</span> <span class='key'>for</span> <span class='nam'>i</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_identity</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>run</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Method to be run in sub-process; can be overridden in sub-class</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_target</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_target</span><span class='op'>(</span><span class='op'>*</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>_args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>_kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>start</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Start child process</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>,</span> <span class='str'>&#39;cannot start a process twice&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_parent_pid</span> <span class='op'>==</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>getpid</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='xx'>\</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&#39;can only start a process object created by current process&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='key'>not</span> <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_daemonic</span><span class='op'>,</span> <span class='xx'>\</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='str'>&#39;daemonic processes are not allowed to have children&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_cleanup</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_Popen</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>Popen</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_Popen</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>from</span> <span class='op'>.</span><span class='nam'>forking</span> <span class='key'>import</span> <span class='nam'>Popen</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='op'>=</span> <span class='nam'>Popen</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_children</span><span class='op'>.</span><span class='nam'>add</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>terminate</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Terminate process; sends SIGTERM signal or uses TerminateProcess()</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span><span class='op'>.</span><span class='nam'>terminate</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>timeout</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Wait until child process terminates</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_parent_pid</span> <span class='op'>==</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>getpid</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>&#39;can only join a child process&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>,</span> <span class='str'>&#39;can only join a started process&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>res</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span><span class='op'>.</span><span class='nam'>wait</span><span class='op'>(</span><span class='nam'>timeout</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>res</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_current_process</span><span class='op'>.</span><span class='nam'>_children</span><span class='op'>.</span><span class='nam'>discard</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>is_alive</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return whether process is alive</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span> <span class='key'>is</span> <span class='nam'>_current_process</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>True</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_parent_pid</span> <span class='op'>==</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>getpid</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>&#39;can only test a child process&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>False</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span><span class='op'>.</span><span class='nam'>poll</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span><span class='op'>.</span><span class='nam'>returncode</span> <span class='key'>is</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>property</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>name</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_name</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>name</span><span class='op'>.</span><span class='nam'>setter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>name</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>,</span> <span class='nam'>str</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>&#39;name must be a string&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_name</span> <span class='op'>=</span> <span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>property</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>daemon</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return whether process is a daemon</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_daemonic</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>daemon</span><span class='op'>.</span><span class='nam'>setter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>daemon</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>daemonic</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Set whether process is a daemon</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>assert</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>,</span> <span class='str'>&#39;process has already started&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_daemonic</span> <span class='op'>=</span> <span class='nam'>daemonic</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>property</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>authkey</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_authkey</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>authkey</span><span class='op'>.</span><span class='nam'>setter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>authkey</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>authkey</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Set authorization key of process</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_authkey</span> <span class='op'>=</span> <span class='nam'>AuthenticationString</span><span class='op'>(</span><span class='nam'>authkey</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>property</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>exitcode</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return exit code of process or `None` if it has yet to stop</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span><span class='op'>.</span><span class='nam'>poll</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='op'>@</span><span class='nam'>property</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>ident</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; Return indentifier (PID) of process or `None` if it has yet to start</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span> <span class='key'>is</span> <span class='nam'>_current_process</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>getpid</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='key'>and</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span><span class='op'>.</span><span class='nam'>pid</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='nam'>pid</span> <span class='op'>=</span> <span class='nam'>ident</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__repr__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span> <span class='key'>is</span> <span class='nam'>_current_process</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>status</span> <span class='op'>=</span> <span class='str'>&#39;started&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_parent_pid</span> <span class='op'>!=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>getpid</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>status</span> <span class='op'>=</span> <span class='str'>&#39;unknown&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>status</span> <span class='op'>=</span> <span class='str'>&#39;initial&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span><span class='op'>.</span><span class='nam'>poll</span><span class='op'>(</span><span class='op'>)</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>status</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>exitcode</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>status</span> <span class='op'>=</span> <span class='str'>&#39;started&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>type</span><span class='op'>(</span><span class='nam'>status</span><span class='op'>)</span> <span class='key'>is</span> <span class='nam'>int</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>status</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>status</span> <span class='op'>=</span> <span class='str'>&#39;stopped&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>status</span> <span class='op'>=</span> <span class='str'>&#39;stopped[%s]&#39;</span> <span class='op'>%</span> <span class='nam'>_exitcode_to_name</span><span class='op'>.</span><span class='nam'>get</span><span class='op'>(</span><span class='nam'>status</span><span class='op'>,</span> <span class='nam'>status</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&#39;&lt;%s(%s, %s%s)&gt;&#39;</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>type</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>__name__</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_name</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='nam'>status</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_daemonic</span> <span class='key'>and</span> <span class='str'>&#39; daemon&#39;</span> <span class='key'>or</span> <span class='str'>&#39;&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'>##</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>_bootstrap</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>from</span> <span class='op'>.</span> <span class='key'>import</span> <span class='nam'>util</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>global</span> <span class='nam'>_current_process</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_children</span> <span class='op'>=</span> <span class='nam'>set</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_counter</span> <span class='op'>=</span> <span class='nam'>itertools</span><span class='op'>.</span><span class='nam'>count</span><span class='op'>(</span><span class='num'>1</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>os</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stdin</span><span class='op'>.</span><span class='nam'>fileno</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='op'>(</span><span class='nam'>OSError</span><span class='op'>,</span> <span class='nam'>ValueError</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>pass</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_current_process</span> <span class='op'>=</span> <span class='nam'>self</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>util</span><span class='op'>.</span><span class='nam'>_finalizer_registry</span><span class='op'>.</span><span class='nam'>clear</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>util</span><span class='op'>.</span><span class='nam'>_run_after_forkers</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>util</span><span class='op'>.</span><span class='nam'>info</span><span class='op'>(</span><span class='str'>&#39;child process calling self.run()&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>run</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>exitcode</span> <span class='op'>=</span> <span class='num'>0</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>finally</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>util</span><span class='op'>.</span><span class='nam'>_exit_function</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>SystemExit</span><span class='op'>,</span> <span class='nam'>e</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>e</span><span class='op'>.</span><span class='nam'>args</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>exitcode</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>type</span><span class='op'>(</span><span class='nam'>e</span><span class='op'>.</span><span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>)</span> <span class='key'>is</span> <span class='nam'>int</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>exitcode</span> <span class='op'>=</span> <span class='nam'>e</span><span class='op'>.</span><span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>e</span><span class='op'>.</span><span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span> <span class='op'>+</span> <span class='str'>&#39;\n&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>.</span><span class='nam'>flush</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>exitcode</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>exitcode</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>import</span> <span class='nam'>traceback</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='str'>&#39;Process %s:\n&#39;</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>.</span><span class='nam'>flush</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>traceback</span><span class='op'>.</span><span class='nam'>print_exc</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>util</span><span class='op'>.</span><span class='nam'>info</span><span class='op'>(</span><span class='str'>&#39;process exiting with exitcode %d&#39;</span> <span class='op'>%</span> <span class='nam'>exitcode</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>exitcode</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># We subclass bytes to avoid accidental transmission of auth keys over network</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>AuthenticationString</span><span class='op'>(</span><span class='nam'>bytes</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__reduce__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>from</span> <span class='op'>.</span><span class='nam'>forking</span> <span class='key'>import</span> <span class='nam'>Popen</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>Popen</span><span class='op'>.</span><span class='nam'>thread_is_spawning</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>TypeError</span><span class='op'>(</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;Pickling an AuthenticationString object is &#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;disallowed for security reasons&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>AuthenticationString</span><span class='op'>,</span> <span class='op'>(</span><span class='nam'>bytes</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>,</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Create object representing the main process</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>class</span> <span class='nam'>_MainProcess</span><span class='op'>(</span><span class='nam'>Process</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_identity</span> <span class='op'>=</span> <span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_daemonic</span> <span class='op'>=</span> <span class='nam'>False</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_name</span> <span class='op'>=</span> <span class='str'>&#39;MainProcess&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_parent_pid</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_popen</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_counter</span> <span class='op'>=</span> <span class='nam'>itertools</span><span class='op'>.</span><span class='nam'>count</span><span class='op'>(</span><span class='num'>1</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_children</span> <span class='op'>=</span> <span class='nam'>set</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_authkey</span> <span class='op'>=</span> <span class='nam'>AuthenticationString</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>urandom</span><span class='op'>(</span><span class='num'>32</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_tempdir</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_current_process</span> <span class='op'>=</span> <span class='nam'>_MainProcess</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>del</span> <span class='nam'>_MainProcess</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Give names to some return codes</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>#</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='nam'>_exitcode_to_name</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'><span class='key'>for</span> <span class='nam'>name</span><span class='op'>,</span> <span class='nam'>signum</span> <span class='key'>in</span> <span class='nam'>signal</span><span class='op'>.</span><span class='nam'>__dict__</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>name</span><span class='op'>[</span><span class='op'>:</span><span class='num'>3</span><span class='op'>]</span><span class='op'>==</span><span class='str'>&#39;SIG&#39;</span> <span class='key'>and</span> <span class='str'>&#39;_&#39;</span> <span class='key'>not</span> <span class='key'>in</span> <span class='nam'>name</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_exitcode_to_name</span><span class='op'>[</span><span class='op'>-</span><span class='nam'>signum</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>name</span><span class='strut'>&nbsp;</span></p>
    
</td>
</tr>
</table>
</div>

</body>
</html>
